package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.model.product.CategoryTrademarkVo;
import com.atguigu.gmall.product.service.BaseCategoryTrademarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/product/baseCategoryTrademark")
public class BaseCategoryTrademarkController {

    private BaseCategoryTrademarkService baseCategoryTrademarkService;

    @Autowired
    public BaseCategoryTrademarkController(BaseCategoryTrademarkService baseCategoryTrademarkService) {
        this.baseCategoryTrademarkService = baseCategoryTrademarkService;
    }

    @GetMapping("/findCurrentTrademarkList/{category3Id}")
    public Result findCurrentTrademarkList(@PathVariable Long category3Id) {
        List<BaseTrademark> list = this.baseCategoryTrademarkService.findCurrentTrademarkList(category3Id);
        return Result.ok(list);
    }

    @GetMapping("/findTrademarkList/{category3Id}")
    public Result findTrademarkList(@PathVariable Long category3Id) {
        List<BaseTrademark> baseTrademarkList = this.baseCategoryTrademarkService.findTrademarkList(category3Id);
        return Result.ok(baseTrademarkList);
    }

    @DeleteMapping("/remove/{category3Id}/{trademarkId}")
    public Result remove(@PathVariable Long category3Id, @PathVariable Long trademarkId) {
        this.baseCategoryTrademarkService.remove(category3Id, trademarkId);
        return Result.ok();
    }

    @PostMapping("/save")
    public Result save(@RequestBody CategoryTrademarkVo trademarkVo) {
        this.baseCategoryTrademarkService.save(trademarkVo);
        return Result.ok();
    }


}
